#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>
#include <cmath>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 3000010;

bool st[N];
LL primes[N], cnt;

void get_primes(int n){
    for(int i = 2; i <= n; i ++){
        if(!st[i]) primes[cnt ++] = i;

        for(int j = 0; primes[j] <= n / i; j ++){
            st[primes[j] * i] = true;
            if(i % primes[j] == 0) break;
        }
    }
}

void solve(){
    LL x;
    cin >> x;
    for(int i = 0; i < cnt; i ++){
        if(x % primes[i] == 0){
            LL t = x / primes[i];

            if(t % primes[i] == 0){
                LL x = t / primes[i];
                cout << primes[i] << " " << x << '\n';
                // break;
            }else{
                LL x = sqrt(t);
                cout << x << " "<< primes[i] << '\n';
                // break;
            }
            break;
        }
    }
}

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    get_primes(N - 1);
    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}